Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement animated features demo component #4

Merged

Conversation

shadowusr
Copy link
Member

@shadowusr shadowusr commented May 12, 2024

What's done?

This PR implements the animated features demo component. Feel free to explore how it looks on different screen sizes in storybook.

Notes:

How to review?

Consider using Github Codespaces for easier navigation.

src/components/FeaturesDemo/index.tsx is a main file describing the whole demo timeline, it's a good place to start.

Copy link

github-actions bot commented May 12, 2024

✅ Successfully deployed static

@shadowusr shadowusr force-pushed the users/shadowusr/HERMIONE-1452.animated-demo-components branch from 510d100 to dce60cc Compare May 13, 2024 23:19
@shadowusr shadowusr changed the title Users/shadowusr/hermione 1452.animated demo components feat: implement animated features demo component May 13, 2024
@shadowusr shadowusr force-pushed the users/shadowusr/HERMIONE-1452.animated-demo-components branch from dce60cc to c5fb5bb Compare May 13, 2024 23:24
@shadowusr shadowusr force-pushed the users/shadowusr/HERMIONE-1452.animated-demo-components branch from c5fb5bb to 6bedb07 Compare May 13, 2024 23:39
@shadowusr shadowusr force-pushed the users/shadowusr/HERMIONE-1452.animated-demo-components branch from 6bedb07 to d190b0f Compare May 13, 2024 23:40
@shadowusr shadowusr force-pushed the users/shadowusr/HERMIONE-1452.animated-demo-components branch from d190b0f to d1dca74 Compare May 13, 2024 23:44
@shadowusr shadowusr force-pushed the users/shadowusr/HERMIONE-1452.animated-demo-components branch from d1dca74 to 2570bfe Compare May 13, 2024 23:49
Copy link
Member

@DudaGod DudaGod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

src/components/FeaturesDemo/index.tsx Show resolved Hide resolved
},
{
id: ConsoleId.SendInputSearch,
messages: ["`<br>> browser.$(\"input[data-data-id='search']\");`"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А что это за сложный селектор такой? Почему просто класс не использовать?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Там должен быть data-role-id, ошибка. Как мне кажется тут уместно использовать data-атрибуты, потому что нам не нужны CSS-селекторы и мы не хотим привязываться ко стилям. Мы хотим достать "input, который для поиска товаров", надежнее всего под это выделить data-атрибут и искать потом по нему, как мне кажется.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.input_type_search решает эту проблему ;)
как минимум, читается это проще

Copy link
Member Author

@shadowusr shadowusr May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вроде бы использование конкретных testid'ов в тестах же является common-, если не best-practice. Я вижу такие преимущества использования разметки data-testid над селекторами:

  • все data-testid можно вырезать при сборке бандла в прод, а селекторы нет
  • селекторы относятся к стилям, если захочется рефакторить стили, поменяются селекторы и все тесты надо будет тоже чинить

Пока что просто поправил на data-testid.

src/components/FeaturesDemo/index.tsx Show resolved Hide resolved
src/components/FeaturesDemo/store.ts Show resolved Hide resolved
src/components/FeaturesDemo/index.tsx Show resolved Hide resolved
src/components/FeaturesDemo/index.tsx Show resolved Hide resolved
src/components/FeaturesDemo/index.tsx Outdated Show resolved Hide resolved
src/components/FeaturesDemo/index.tsx Outdated Show resolved Hide resolved
src/components/FeaturesDemo/index.tsx Outdated Show resolved Hide resolved
@@ -43,25 +70,16 @@ const config: StorybookConfig = {
rules: [
...(config.module?.rules as Record<string, any>[]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where can I view these rules? can't find them

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we extend storybook's webpack config with some custom rules. By adding ...config.module.rules we make sure to include original rules, we don't want to throw them away when adding ours.

Docs: https://storybook.js.org/docs/api/main-config-webpack-final

rules: _.omit(geminiTesting.rules, [
// Rules that conflict with typescript-eslint.
"no-undef",
"no-unused-vars",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to exclude this rule?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it conflicts with typescript-eslint, as stated in the comment above. It provides its own rule, @typescript-eslint/no-unusd-vars, because the original one doesn't work well with TS code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jpg? really? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with jpg? I'm trying to squeeze assets as tightly as I can so that landing page opens up fast enough even on slow internet. Pics are not of great quality, but good enough for demo purposes, IMO


export function Collapsible(props: CollapsibleProps) {
return (
<div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for better code readability we need to add selectors (for example, .collapsible) instead of leaving empty elements

Copy link
Member Author

@shadowusr shadowusr May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, added unused collapsible class for the sake of better devtools experience and corresponding class names for other components as well. I still think that it kinda diminishes some of the benefits of using Tailwind though

src/components/Collapsible/index.tsx Outdated Show resolved Hide resolved
src/components/FeaturesDemo/AnimatedCursor.tsx Outdated Show resolved Hide resolved
},
{
id: ConsoleId.SendInputSearch,
messages: ["`<br>> browser.$(\"input[data-data-id='search']\");`"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.input_type_search решает эту проблему ;)
как минимум, читается это проще

ref={codeElementRef}
>
<div
className="absolute text-right text-blue-400 opacity-40"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolute... again... instead of simple display: inline-block

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, I don't want line numbers to affect code in any way and don't want to deal with inline blocks wrapping/overflowing/etc, that's why I positioned them absolutely. What's the benefit of using inline-block here?

const controller = new AbortController();
const signal = controller.signal;

const steps: (() => void | Promise<void>)[] = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imho, it would be better to move stept to the separate file(files) for more readability

Copy link
Member Author

@shadowusr shadowusr May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this thought has crossed my mind, however A LOT of things (many refs, signals, store data, etc.) are used inside steps (via closures), if we move them outside, we'll severely worsen readability in that aspect, so in the end I've decided against it.

Otherwise we'll need to construct a function which takes 20+ params (even if packed into an object) and write corresponding types for them all.

Do you think it's worth it?

containerRef: RefObject<HTMLDivElement>,
) => {
const offsetTop =
lineRef.current!.offsetTop - containerRef.current!.parentElement!.clientHeight + 80;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

80?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a comment. It's just an arbitrary value, to add some room underneath the line, was chosen by trial and error.

@shadowusr shadowusr merged commit bb92a86 into master May 26, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants